/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package carcassonne.gameplay.listObjects;

import java.util.ArrayList;
import java.util.List;

/**
 * Contains a list of all the available positions the current tile can be placed.
 * 
 * @author tylerb
 */
public class NextAvailablePositions {
    private static List <Integer> nextAvailablePositions = new ArrayList();
    
    public static void initialize(int boardSize) {
        for (int i=0; i<boardSize; i++) {
            nextAvailablePositions.add(i);
        }
        
    }

    public static List getNextAvailablePositionsList() {
        return nextAvailablePositions;
    }

    public static void addPosition(int position) {
        nextAvailablePositions.add(position);
    }
    
    public static void removePosition(int position) {
        /*By casting position as an Integer, we can remove the first element
          with that value instead of the element at that position in the list.
         */
        nextAvailablePositions.remove((Integer) position);
    }
    
    public static boolean containsPosition(int position) {
        return nextAvailablePositions.contains((Integer) position);
    }
    
    public String toString() {
        String ret = "";
        for (int i=0; i<nextAvailablePositions.size(); i++) {
            ret.concat(nextAvailablePositions.get(i).toString() + "\n");
        }
        return ret;
    }
    
    public static String print() {
        return nextAvailablePositions.toString();
    }
}
